class PingsController < ApplicationController
  # GET /pings
  # GET /pings.xml
  def index
    @pings = Ping.find(:all)

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @pings.to_xml }
    end
  end

  # GET /pings/1
  # GET /pings/1.xml
  def show
    @ping = Ping.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @ping.to_xml }
    end
  end

  # GET /pings/new
  def new
    @ping = Ping.new
  end

  # GET /pings/1;edit
  def edit
    @ping = Ping.find(params[:id])
  end

  # POST /pings
  # POST /pings.xml
  def create
    @ping = Ping.new(params[:ping])

    respond_to do |format|
      if @ping.save
        flash[:notice] = 'Ping was successfully created.'
        format.html { redirect_to ping_url(@ping) }
        format.xml  { head :created, :location => ping_url(@ping) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @ping.errors.to_xml }
      end
    end
  end

  # PUT /pings/1
  # PUT /pings/1.xml
  def update
    @ping = Ping.find(params[:id])

    respond_to do |format|
      if @ping.update_attributes(params[:ping])
        flash[:notice] = 'Ping was successfully updated.'
        format.html { redirect_to ping_url(@ping) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @ping.errors.to_xml }
      end
    end
  end

  # DELETE /pings/1
  # DELETE /pings/1.xml
  def destroy
    @ping = Ping.find(params[:id])
    @ping.destroy

    respond_to do |format|
      format.html { redirect_to pings_url }
      format.xml  { head :ok }
    end
  end
end
